<%--
    Document   : edit
    Created on : 2011-06-19, 17:38:03
    Author     : Sobot
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title>JSP Page</title>
            <link rel="stylesheet" type="text/css" href="media/css/common.css" />
            <link rel="stylesheet" type="text/css" href="../media/css/common.css" />
            <link rel="stylesheet" type="text/css" href="media/css/form.css" />
            <link rel="stylesheet" type="text/css" href="../media/css/form.css" />
        </head>

        <body>

            <h:form id="logout" rendered="#{client.name != null}">
                <h:outputText value="Zalogowano jako #{client.name} #{client.surname} "/>
                <h:outputText value=" | Aktualna wartość koszyka to #{cart.currentValue} zł"/>

                <div id="user-panel">
                    <h:commandLink action="cart" styleClass="inlineItem">Zawartość koszyka </h:commandLink>
                    <h:commandLink action="#{client.logout}" styleClass="inlineItem">Wyloguj</h:commandLink>
                </div>

            </h:form>
            
            <div id="main-wrapper">
                <h1><h:outputText value="Edycja autora"/></h1>

                <h:form>
                    <h:commandLink action="index" value="Strona główna" styleClass="submit"/>
                    <h:commandLink action="admin" value="Wyświetl autorów" styleClass="submit"/>
                </h:form>

                <h:form id="book">

                    <div>
                        <h:inputHidden id="id" value="#{authorHelper.id}" />
                        <label for="title">Imię:</label>
                        <h:inputText id="name" value="#{authorHelper.name}" required="true" >
                            <f:validateLength maximum="40" minimum="3" />
                        </h:inputText>
                    </div>

                    <div>
                        <label for="description">Nazwisko:</label>
                        <h:inputText id="surname" value="#{authorHelper.surname}" required="true" >
                            <f:validateLength maximum="40" minimum="3" />
                        </h:inputText>
                    </div>

                    <div>
                        <label for="books">Książki: </label>
                        <h:selectManyListbox value="#{authorHelper.booksId}">
                            <f:selectItems value="#{bookDao.allBooks}" var="item"
                                           itemLabel="#{item.title}"/>
                        </h:selectManyListbox>
                    </div>

                    <h:commandButton action="#{authorHelper.update}" value="Zatwierdz zmiany" styleClass="submit"/>
                </h:form>
            </div>
        </body>
    </html>
</f:view>
